<?php
/** 
 * @uses 		队列数据接收
 * @author 		Duan
 * @version 	1.0
 * @copyright	Yihuan							  
 */

namespace Common\Model;


class ReceiveModel 
{

	/**
	 * @uses 	挂号
	 * @return  boolen
	 */
	public function registrationFetchAjax()
	{
		return $this->pushRedis($_POST);
	}

	/**
	 * @uses 	缴费 
	 * @return  boolen
	 */
	public function outPatientPayAjax()
	{
		return $this->pushRedis($_POST);
	}

	/**
	 * @uses 	扫码付款
	 * @return 	boolen
	 */
	public function scanOrderAjax()
	{
		return $this->pushRedis($_POST);
	}

	/**
	 * @uses 	存储队列数据
	 * @param 	$params 数据 
	 * @return 	int
	 */
	private function pushRedis($params)
	{
		$receiveKey 	= C('RECEIVE_KEY');
		$data 	= ['call_fun' => ACTION_NAME , 'time' => time() , 'num' => 1 , 'out_trade_no' => $params['out_trade_no'] , 'hospitalId' => $params['hospitalId'] , 'params' => $params];
		$redis 	= \Common\Model\ServeModel::serveRedis();
		$result = $redis->rpush($receiveKey , json_encode($data , JSON_UNESCAPED_UNICODE));
		return $result ? 200 : 401;
	}

	/**
	 * @uses 	访问不存子啊的方法
	 * @param 	$name 	方法名
	 * @param 	$args 	参数
	 * @return 	int
	 */
	function __call($name , $args)
	{
		return 404;
	}
}